package com.zc.demo.aop;

import org.aspectj.lang.ProceedingJoinPoint;

/**
 * 定义观众切面
 * Created by zhangchi9 on 2016/11/4.
 */
public class Audience {

    public void takeSeats(){
        System.out.println("表演之前获得座位！");
    }

    public void turnOffcellPhones(){
        System.out.println("表演之前关闭手机！");
    }

    public void applaud(){
        System.out.println("表演之后要鼓掌!");
    }

    public void demandRefund(){
        System.out.println("表演失败后我们要求退票！");
    }
    public void watchPerformance(ProceedingJoinPoint joinPoint){
        try {
            /**表演之前**/
            System.out.println("表演之前获得座位！");
            System.out.println("表演之前关闭手机！");
            long start = System.currentTimeMillis();

            /** 执行被通知的方法 **/
            joinPoint.proceed();

            /**表演之后*/
            long end = System.currentTimeMillis();
            System.out.println("表演之后要鼓掌!");
            System.out.println(end-start);
        } catch (Throwable throwable) {
            System.out.println("表演失败后我们要求退票！");
            throwable.printStackTrace();
        }
    }
}
